<style>
    .panel-post {
        position: relative;
    }

    .table>tbody>tr>th, .table>tbody>tr>td{
        text-align: center;
		vertical-align: middle;
    }
</style>
<div class="container mt-20">
    <div id="content-container">
        <div class="row">
            <div class="col-md-3">
                {include file="common/sidenav" /}
            </div>
            <div class="col-md-9">
                <div class="panel panel-default panel-user">
                    <div class="panel-body">
                        <div class="panel-post">
                            <h2 class="page-header">{$shebei.device_name}</h2>
							<div style="position:absolute;bottom:12px;right:0;">
                                <form id="videoForm" action="" class="form-inline" method="get" role="form">
                                    <input type="text" class="form-control datetimepicker" name="dateline" id="dateline" placeholder="请选择时间" value="{$Think.get.dateline|default=date('Y-m-d')}">
                                    <a href="javascript:;" class="btn btn-primary btn-post" onclick="$('#videoForm').submit()"><i class="fa fa-edit"></i> 搜索</a>
                                </form>
                            </div>
                        </div>
						<div class="row">
							<table id="table" class="table table-bordered table-hover" width="100%">
							<tr><th>序号</th><th>开始时间</th><th>结束时间</th><th>录像长度</th><th>创建时间</th><th>操作</th></tr>
							{if $fileList}
							{volist name='fileList' id='item'}
								<tr>
									<td>{:$key+1}</td>
									<td>{:date('Y-m-d H:i:s', $item.startTime/1000)}</td>
									<td>{:date('Y-m-d H:i:s', $item.endTime/1000)}</td>
									<td>{$item.videoLong/1000}秒</td>
									<td>{:date('Y-m-d H:i:s', $item.createTime/1000)}</td>
									<td><a onclick="luzhi({$shebei.id}, {$item.startTime}, {$item.endTime})" href="javascript:;" class="btn btn-success btn-small">生成视频</a></td>
								</tr>
							{/volist}
							{/if}
							</table>
						</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
function luzhi(id, startTime, endTime)
{
	var index = Layer.load();
	$.ajax({
		type:'get',
		url:"{:url('index/bankuai/transcribe')}?id="+id+"&startTime="+startTime+"&endTime="+endTime,
		dataType:'json',
		success:function(data){
			Layer.close(index);
			if(data.code == 1)
			{
				location.href = "{:url('index/bankuai/filelist')}?id="+id+"&taskid="+data.taskid;
			}
			else if(data.code == 2)
			{
				Layer.msg('视频文件正在生成，请稍等片刻...',{time:15000}, function(){
					location.href = "{:url('index/bankuai/filelist')}?id="+id+"&taskid="+data.taskid;
				});
			}
			else
			{
				Layer.msg(data.msg);
			}
		}
	});
}
</script>